package cn.secby.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.secby.common.log.annotation.Log;
import cn.secby.common.log.enums.BusinessType;
import cn.secby.common.security.annotation.RequiresPermissions;
import cn.secby.wms.domain.LogisticsCompany;
import cn.secby.wms.service.ILogisticsCompanyService;
import cn.secby.common.core.web.controller.BaseController;
import cn.secby.common.core.web.domain.AjaxResult;
import cn.secby.common.core.utils.poi.ExcelUtil;
import cn.secby.common.core.web.page.TableDataInfo;

/**
 * 物流公司Controller
 * 
 * @author hushuo
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/logisticsCompany")
public class LogisticsCompanyController extends BaseController
{
    @Autowired
    private ILogisticsCompanyService logisticsCompanyService;

    /**
     * 查询物流公司列表
     */
    @RequiresPermissions("wms:logisticsCompany:list")
    @GetMapping("/list")
    public TableDataInfo list(LogisticsCompany logisticsCompany)
    {
        startPage();
        List<LogisticsCompany> list = logisticsCompanyService.selectLogisticsCompanyList(logisticsCompany);
        return getDataTable(list);
    }

    /**
     * 导出物流公司列表
     */
    @RequiresPermissions("wms:logisticsCompany:export")
    @Log(title = "物流公司", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LogisticsCompany logisticsCompany)
    {
        List<LogisticsCompany> list = logisticsCompanyService.selectLogisticsCompanyList(logisticsCompany);
        ExcelUtil<LogisticsCompany> util = new ExcelUtil<LogisticsCompany>(LogisticsCompany.class);
        util.exportExcel(response, list, "物流公司数据");
    }

    /**
     * 获取物流公司详细信息
     */
    @RequiresPermissions("wms:logisticsCompany:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(logisticsCompanyService.selectLogisticsCompanyById(id));
    }

    /**
     * 新增物流公司
     */
    @RequiresPermissions("wms:logisticsCompany:add")
    @Log(title = "物流公司", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LogisticsCompany logisticsCompany)
    {
        return toAjax(logisticsCompanyService.insertLogisticsCompany(logisticsCompany));
    }

    /**
     * 修改物流公司
     */
    @RequiresPermissions("wms:logisticsCompany:edit")
    @Log(title = "物流公司", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LogisticsCompany logisticsCompany)
    {
        return toAjax(logisticsCompanyService.updateLogisticsCompany(logisticsCompany));
    }

    /**
     * 删除物流公司
     */
    @RequiresPermissions("wms:logisticsCompany:remove")
    @Log(title = "物流公司", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(logisticsCompanyService.deleteLogisticsCompanyByIds(ids));
    }
}
